package com.qfjy.homework.gongzhenyun;

/**
 * 代理类
 * @author : gzy
 * @version : 1.0
 * @date : 2022/11/10 20:29
 */
public class ProxyImage implements Image{

    private RealImage realImage;
    private String fileName;

    public ProxyImage(String fileName){
        this.fileName = fileName;
    }

    @Override
    public void display() {
        //被代理对象不存在，创建被代理对象调用该方法
        if(realImage == null){
            realImage = new RealImage(fileName);
        }
        //被代理对象存在，直接调用该方法
        realImage.display();
    }
}
